package com.cmsz.order.remote;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.remoting.caucho.HessianProxyFactoryBean;

import com.cmsz.order.remote.AliRemoteService;
import com.cmsz.order.remote.BetterRemoteService;
import com.cmsz.order.remote.UnionRemoteService;
import com.cmsz.order.remote.WxRemoteService;

@Configuration
public class SecurityConfiguration {

	@Autowired
	Environment env;
	
	@Bean(name = "BankSecurityRemoting")
	public HessianProxyFactoryBean getMerSecurityBean() {
		HessianProxyFactoryBean factoryBean = new HessianProxyFactoryBean();
		factoryBean.setServiceUrl(env.getProperty("security.endpoint"));
		factoryBean.setServiceInterface(BetterRemoteService.class);
		return factoryBean;
	}
	
	@Bean(name = "aliRemoteService")
	public HessianProxyFactoryBean getAliRemoteService() {
		HessianProxyFactoryBean factoryBean = new HessianProxyFactoryBean();
		factoryBean.setServiceUrl(env.getProperty("ali.security.endpoint"));
		factoryBean.setServiceInterface(AliRemoteService.class);
		return factoryBean;
	}
	
	@Bean(name = "wxRemoteService")
	public HessianProxyFactoryBean getWxRemoteService() {
		HessianProxyFactoryBean factoryBean = new HessianProxyFactoryBean();
		factoryBean.setServiceUrl(env.getProperty("wx.security.endpoint"));
		factoryBean.setServiceInterface(WxRemoteService.class);
		return factoryBean;
	}
	
	@Bean(name = "unionRemoteService")
	public HessianProxyFactoryBean getUnionRemoteService() {
		HessianProxyFactoryBean factoryBean = new HessianProxyFactoryBean();
		factoryBean.setServiceUrl(env.getProperty("union.security.endpoint"));
		factoryBean.setServiceInterface(UnionRemoteService.class);
		return factoryBean;
	}
	
}
